Skip to content

feat(id): invite terms extension — versioned postcard InviteBody (#12983) - #13046

Merged
dezren39 merged 1 commit into
mainfrom
lane-hn/12983-invite-terms
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-hn/12983-invite-terms

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What

Implements step 1 of the #5751 design record's implementation shape (§5) for #12983: the signed invite event's body now carries the delegation terms.

  • v2 wire form — IDINV magic + version byte (the IDKEY envelope's shape), postcard body per id: design: Wire format & transport adapters — postcard schema, non-UDP carriers, relays/proxies #5674, signature over a v2 domain tag. New fields: target (group, or world + its fronting group), uses_cap: Option<u32>, depth_remaining: u8, parent_digest: Option<[u8;32]>, redeemer: Option<[u8;32]>.
  • v1 stays readable — the fixed layout is the legacy read form. Parsed v1 bodies carry the legacy terms (group target, no cap, depth 0, no parent, no pin) and re-serialize in the v1 form, so existing signatures still verify. InviteEvent::sign now mints v2; sign_terms mints with terms.
  • §1 budgets — a v2 body over 512 bytes is refused at decode and at mint; Invitation::link / Invitation::bare mint constructors refuse a paste form over 512 chars.
  • §2/§3 mechanics — InviteTerms::source / ::link land the defaults (open-delegation depth 1, moderator-grant depth 0, link 7-day expiry + 25-use cap); with_depth caps a source depth at 3; InviteBody::child_terms refuses a re-invite depth not strictly below the parent's and stamps parent_digest from the parent's new digest(); check_redeemer enforces the pin; admits_redemption applies the use cap (the counting itself is step 2's journal).

check_route is unchanged apart from reading the group through InviteBody::group() (the target's anchor group). id-directory gains the postcard dependency in the sibling crates' style; the lockfile diff is that one edge.

Evidence

  • cargo test -p id-directory — 281 passed / 0 failed, including 9 invite-event unit tests (6 new: every-term round-trip, v1 parse + re-serialize, over-budget decode refusal, redeemer pin, depth monotonicity, defaults, use cap).
  • cargo test --test invites (facade) — 23 passed / 0 failed (3 new: v1 event still parses with legacy terms, terms round-trip + route check stays Verified, over-budget paste mint refused). One existing test was updated where the v1 role-byte offset and body.group field access were tied to the old form.
  • rustfmt --check clean on all changed files; cargo clippy -p id-directory --all-targets exits 0 with no warning sites in the changed files.

Merge danger

Door: two-way for reading (both forms parse), one-way for writing (new mints are v2-only; there is no v2→v1 downgrade path, by design — v1 cannot carry the terms).

Blast radius: the invites module of id-directory; no other crate constructs InviteBody or calls check_route (verified by grep across the repo). The one theoretical ambiguity — a v1 inviter key beginning with the v2 magic bytes — is named in the module docs; keys are random and v1 is a legacy read form.

This closes #12983's step-1 scope. Follow-ons stay where they were: #12922 (capability_pin term) attaches to this terms object; redemption journaling / counting is §5 step 2.

Closes #12983


Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

)

Step 1 of the #5751 design record's implementation shape (§5): the signed
invite event's body gains the delegation terms.

- v2 wire form: `IDINV` magic + version byte, postcard body (#5674), then
  the signature over a v2 domain tag. The body carries `target` (a group,
  or a world + its fronting group), `uses_cap`, `depth_remaining`,
  `parent_digest`, and a `redeemer` pin, alongside the v1 fields.
- The v1 fixed layout is now the legacy read form: events already minted
  in it keep parsing and verifying, carry the legacy terms (group target,
  no cap, depth 0, no parent, no pin), and re-serialize in their own form
  so their signatures still verify.
- §1 budgets enforced: a v2 body over 512 bytes is refused at decode (and
  at mint); `Invitation::link`/`Invitation::bare` refuse a paste form over
  512 characters at mint.
- §2/§3 mechanics on the body: `InviteTerms::source`/`link` land the
  defaults (open delegation depth 1, moderator grant depth 0, link 7-day
  expiry + 25-use cap), `with_depth` enforces the source cap of 3,
  `child_terms` refuses a re-invite depth that is not strictly less than
  the parent's and stamps the parent digest, `check_redeemer` enforces
  the pin, `admits_redemption` applies the use cap.

Oracles (the issue's): every-term body round-trips byte-identically; a v1
event still parses; an over-budget body is refused at decode and an
over-budget paste form at mint; a pinned invite refuses another redeemer;
depth never increases along a re-mint; link/source defaults land.

Verified: cargo test -p id-directory — 281 passed / 0 failed (9 invite
event tests, 6 new); cargo test --test invites (facade) — 23 passed /
0 failed (3 new); rustfmt clean on the changed files; Cargo.lock gains
only the postcard dependency edge for id-directory.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b85d57f2-3486-4175-b8ee-4f589889983a
Commits

Reviewing files that changed from the base of the PR and between 38f9052 and 5aee03f.

Files ignored due to path filters: 1

  • pkgs/id/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 5

  • pkgs/id/crates/id-directory/Cargo.toml
  • pkgs/id/crates/id-directory/src/invites/event.rs
  • pkgs/id/crates/id-directory/src/invites/invitation.rs
  • pkgs/id/crates/id-directory/src/invites/mod.rs
  • pkgs/id/tests/invites.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T07:38:25.094034Z 5aee03f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id: implement #5751 invite terms extension — InviteBody target/uses/depth/redeemer/parent, postcard versioning, 512-byte budget

1 participant